﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Server
{
	public partial class Form3 : Form
	{

		public string OutValue;
		DataTable rows;
		string path;
		public Form3(DataTable _rows,string _path)
		{
			path = _path;
			rows = _rows;
			InitializeComponent();
		}

		private void Form3_Load(object sender, EventArgs e)
		{
			dataGridView1.DataSource = rows;
		}

		private void button1_Click(object sender, EventArgs e)
		{
			DataTable dt = (DataTable )dataGridView1.DataSource;
			foreach (DataRow item in dt.Rows)
			{
				string filename=item[6].ToString();
				string type = item[9].ToString();
				if(File.Exists(path + filename + "." + type))
				{
					File.Delete(path + filename + "." + type);
				}
				dataTools data = new dataTools(configClass.databaseip, configClass.databaseusername, "music", configClass.databaseport, configClass.psw);
				data.deleteAnd("V1", new string[] { "mid" }, new string[] { filename });
			}
			this.OutValue = "删除成功";
			this.DialogResult = DialogResult.OK;
			this.Close();

		}
		protected override void OnClosing(CancelEventArgs e)
		{
			base.OnClosing(e);

		}

		private void button2_Click(object sender, EventArgs e)
		{

			this.OutValue = "取消删除";
			this.DialogResult = DialogResult.OK;
			this.Close();
		}
	}
}
